package com.woniu.apartment.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.woniu.apartment.domain.Items;
import com.woniu.apartment.service.IItemsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 房租内包含费用项目Controller
 * 
 * @author yy
 * @date 2023-04-03
 */
@RestController
@RequestMapping("/apartment/tbitems")
@Api("房租内包含费用项目管理")
public class ItemsController extends BaseController
{
    @Autowired
    private IItemsService itemsService;

    /**
     * 查询房租内包含费用项目列表
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbitems:list')")
    @GetMapping("/list")
    @ApiOperation("房租内包含费用项目分页查询")
    public TableDataInfo list(Items items)
    {
        startPage();
        List<Items> list = itemsService.selectItemsList(items);
        return getDataTable(list);
    }

    /**
     * 导出房租内包含费用项目列表
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbitems:export')")
    @Log(title = "房租内包含费用项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("房租内包含费用项目导出")
    public void export(HttpServletResponse response, Items items)
    {
        List<Items> list = itemsService.selectItemsList(items);
        ExcelUtil<Items> util = new ExcelUtil<Items>(Items.class);
        util.exportExcel(response, list, "房租内包含费用项目数据");
    }

    /**
     * 获取房租内包含费用项目详细信息
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbitems:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("根据主键查询房租内包含费用项目")
    @ApiImplicitParam(name = "ids", value = "用户ID", required = true, dataType = "Long")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(itemsService.selectItemsById(id));
    }

    /**
     * 新增房租内包含费用项目
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbitems:add')")
    @Log(title = "房租内包含费用项目", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("添加房租内包含费用项目")
    public AjaxResult add(@RequestBody Items items)
    {
        return toAjax(itemsService.insertItems(items));
    }

    /**
     * 修改房租内包含费用项目
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbitems:edit')")
    @Log(title = "房租内包含费用项目", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("更新房租内包含费用项目")
    public AjaxResult edit(@RequestBody Items items)
    {
        return toAjax(itemsService.updateItems(items));
    }

    /**
     * 删除房租内包含费用项目
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbitems:remove')")
    @Log(title = "房租内包含费用项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除房租内包含费用项目")
    @ApiImplicitParam(name = "ids", value = "主键数组", required = true, dataType = "Long")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(itemsService.deleteItemsByIds(ids));
    }
}
